﻿<office:OfficeWindow xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		xmlns:ext="clr-namespace:Microsoft.Windows.Shell;assembly=Microsoft.Windows.Shell"
		xmlns:office="clr-namespace:Daytimer.Fundamentals;assembly=Daytimer.Fundamentals"
		xmlns:System="clr-namespace:System;assembly=mscorlib" x:Class="Daytimer.Controls.CustomDictionaryEditor"
		ShowActivated="True" Title="Custom Spelling Dictionary" Width="625" Height="400" MinWidth="350" MinHeight="200"
		WindowStartupLocation="CenterScreen" Foreground="{DynamicResource Black}">
	<Grid>
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto" />
			<RowDefinition />
			<RowDefinition Height="Auto" />
		</Grid.RowDefinitions>
		<WrapPanel x:Name="statusText" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="20"
				Visibility="Collapsed">
			<TextBlock Text="No search results." Foreground="#FFB2B2B2" IsHitTestVisible="False" />
			<Button x:Name="addButton" Style="{StaticResource LinkText}" Content="Add to dictionary."
					Foreground="{DynamicResource LinkTextForeground}" VerticalAlignment="Center" Padding="0"
					Margin="5,0,0,0" Click="addButton_Click" />
		</WrapPanel>
		<ListBox x:Name="listBox" Grid.Row="1" Background="{DynamicResource White}" BorderThickness="0" Margin="20"
				VirtualizingStackPanel.VirtualizationMode="Recycling"
				ScrollViewer.HorizontalScrollBarVisibility="Disabled"
				PreviewMouseLeftButtonDown="listBox_PreviewMouseLeftButtonDown">
			<ListBox.Resources>
				<Style x:Key="DeleteButton" TargetType="{x:Type Button}">
					<Setter Property="Width" Value="22" />
					<Setter Property="Height" Value="22" />
					<Setter Property="HorizontalAlignment" Value="Center" />
					<Setter Property="VerticalAlignment" Value="Center" />
					<Setter Property="Focusable" Value="False" />
					<Setter Property="Cursor" Value="Arrow" />
					<Setter Property="Template">
						<Setter.Value>
							<ControlTemplate TargetType="{x:Type Button}">
								<Border x:Name="border">
									<Border.Background>
										<SolidColorBrush x:Name="background" Color="Transparent" />
									</Border.Background>
									<VisualStateManager.VisualStateGroups>
										<VisualStateGroup x:Name="CommonStates">
											<VisualState x:Name="Normal" />
											<VisualState x:Name="MouseOver">
												<Storyboard>
													<ColorAnimationUsingKeyFrames Storyboard.TargetName="background"
															Storyboard.TargetProperty="Color">
														<EasingColorKeyFrame KeyTime="0"
																Value="{DynamicResource CaptionMouseOver}" />
													</ColorAnimationUsingKeyFrames>
												</Storyboard>
											</VisualState>
											<VisualState x:Name="Pressed">
												<Storyboard>
													<ColorAnimationUsingKeyFrames Storyboard.TargetName="background"
															Storyboard.TargetProperty="Color">
														<EasingColorKeyFrame KeyTime="0"
																Value="{DynamicResource CaptionPressed}" />
													</ColorAnimationUsingKeyFrames>
												</Storyboard>
											</VisualState>
											<VisualState x:Name="Disabled">
												<Storyboard>
													<DoubleAnimationUsingKeyFrames Storyboard.TargetName="border"
															Storyboard.TargetProperty="Opacity">
														<EasingDoubleKeyFrame KeyTime="0" Value="0.5" />
													</DoubleAnimationUsingKeyFrames>
												</Storyboard>
											</VisualState>
										</VisualStateGroup>
									</VisualStateManager.VisualStateGroups>
									<Path HorizontalAlignment="Center" VerticalAlignment="Center"
											Data="{Binding Content, RelativeSource={RelativeSource TemplatedParent}}"
											Stroke="{TemplateBinding Foreground}" SnapsToDevicePixels="True"
											StrokeThickness="2" IsHitTestVisible="False" />
								</Border>
							</ControlTemplate>
						</Setter.Value>
					</Setter>
				</Style>
				<Style x:Key="DictionaryEntry" TargetType="{x:Type ListBoxItem}">
					<Setter Property="Padding" Value="10,2" />
					<Setter Property="BorderThickness" Value="0" />
					<Setter Property="Cursor" Value="Arrow" />
					<Setter Property="Foreground" Value="{DynamicResource Black}" />
					<Setter Property="Background" Value="{DynamicResource White}" />
					<Setter Property="Template">
						<Setter.Value>
							<ControlTemplate TargetType="{x:Type ListBoxItem}">
								<Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}"
										BorderThickness="{TemplateBinding BorderThickness}"
										Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}"
										SnapsToDevicePixels="True">
									<Grid ClipToBounds="True">
										<Grid.CacheMode>
											<BitmapCache />
										</Grid.CacheMode>
										<Grid.ColumnDefinitions>
											<ColumnDefinition Width="*" />
											<ColumnDefinition Width="Auto" />
										</Grid.ColumnDefinitions>
										<TextBlock HorizontalAlignment="Left" VerticalAlignment="Center"
												TextTrimming="CharacterEllipsis"
												Text="{Binding Content, RelativeSource={RelativeSource TemplatedParent}}"
												IsHitTestVisible="False" />
										<Button x:Name="deleteButton" Visibility="Hidden"
												Style="{StaticResource DeleteButton}" Grid.Column="4"
												Content="M 0.5 0.5 7.5 7.5 M 0.5 7.5 7.5 0.5"
												Foreground="{Binding Foreground, ElementName=title}" Margin="4,0,0,0"
												ToolTip="Delete" Click="deleteButton_Click" />
									</Grid>
								</Border>
								<ControlTemplate.Triggers>
									<MultiTrigger>
										<MultiTrigger.Conditions>
											<Condition Property="IsMouseOver" Value="True" />
										</MultiTrigger.Conditions>
										<Setter Property="Background" TargetName="Bd"
												Value="{DynamicResource Appointment}" />
										<Setter Property="Visibility" TargetName="deleteButton" Value="Visible" />
										<Setter Property="TextElement.Foreground" TargetName="Bd" Value="#FF3C3C3C" />
									</MultiTrigger>
									<Trigger Property="IsSelected" Value="True">
										<Setter Property="Visibility" TargetName="deleteButton" Value="Visible" />
									</Trigger>
									<MultiTrigger>
										<MultiTrigger.Conditions>
											<Condition Property="Selector.IsSelectionActive" Value="False" />
											<Condition Property="IsSelected" Value="True" />
										</MultiTrigger.Conditions>
										<Setter Property="Background" TargetName="Bd" Value="#3DDADADA" />
									</MultiTrigger>
									<MultiTrigger>
										<MultiTrigger.Conditions>
											<Condition Property="Selector.IsSelectionActive" Value="True" />
											<Condition Property="IsSelected" Value="True" />
										</MultiTrigger.Conditions>
										<Setter Property="Background" TargetName="Bd" Value="{DynamicResource Blue}" />
										<Setter Property="TextElement.Foreground" TargetName="Bd" Value="#FF3C3C3C" />
									</MultiTrigger>
									<Trigger Property="IsEnabled" Value="False">
										<Setter Property="TextElement.Foreground" TargetName="Bd"
												Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
									</Trigger>
								</ControlTemplate.Triggers>
							</ControlTemplate>
						</Setter.Value>
					</Setter>
				</Style>
			</ListBox.Resources>
			<ListBox.Template>
				<ControlTemplate TargetType="{x:Type ListBox}">
					<Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}"
							BorderThickness="{TemplateBinding BorderThickness}"
							Background="{TemplateBinding Background}" Padding="1" SnapsToDevicePixels="True">
						<ScrollViewer Focusable="False" Padding="{TemplateBinding Padding}">
							<ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
						</ScrollViewer>
					</Border>
					<ControlTemplate.Triggers>
						<Trigger Property="IsEnabled" Value="False">
							<Setter Property="Background" TargetName="Bd"
									Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
						</Trigger>
						<MultiTrigger>
							<MultiTrigger.Conditions>
								<Condition Property="IsGrouping" Value="True" />
							</MultiTrigger.Conditions>
							<Setter Property="ScrollViewer.CanContentScroll" Value="False" />
						</MultiTrigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</ListBox.Template>
			<ListBoxItem x:Name="addNewItem" HorizontalContentAlignment="Stretch" Selected="addNewItem_Selected"
					Unselected="addNewItem_Unselected">
				<Grid Background="{DynamicResource White}">
					<TextBlock x:Name="addNewTextWatermark" Text="Add a new word" VerticalAlignment="Center"
							HorizontalAlignment="Left" Margin="4,0,0,0" Foreground="#FFA9A9A9" />
					<TextBox x:Name="addNewText" Background="Transparent" VerticalContentAlignment="Center"
							GotKeyboardFocus="addNewText_GotKeyboardFocus" Padding="1,2"
							TextChanged="addNewText_TextChanged" PreviewKeyDown="addNewText_PreviewKeyDown" />
				</Grid>
			</ListBoxItem>
		</ListBox>
		<Grid Grid.Row="2" Background="{DynamicResource DialogFooter}">
			<Grid.ColumnDefinitions>
				<ColumnDefinition />
				<ColumnDefinition Width="Auto" />
			</Grid.ColumnDefinitions>
			<Grid Background="{DynamicResource White}" Margin="20,20,10,20">
				<Grid.Resources>
					<Style x:Key="CancelButton" TargetType="{x:Type Button}">
						<Setter Property="Width" Value="22" />
						<Setter Property="Height" Value="22" />
						<Setter Property="HorizontalAlignment" Value="Center" />
						<Setter Property="VerticalAlignment" Value="Center" />
						<Setter Property="Focusable" Value="False" />
						<Setter Property="Cursor" Value="Arrow" />
						<Setter Property="Foreground" Value="{DynamicResource Black}" />
						<Setter Property="Template">
							<Setter.Value>
								<ControlTemplate TargetType="{x:Type Button}">
									<Border Background="Transparent">
										<Path x:Name="path" HorizontalAlignment="Center" VerticalAlignment="Center"
												Data="{Binding Content, RelativeSource={RelativeSource TemplatedParent}}"
												Stroke="{TemplateBinding Foreground}" SnapsToDevicePixels="True"
												StrokeThickness="2" />
									</Border>
									<ControlTemplate.Triggers>
										<Trigger Property="IsMouseOver" Value="True">
											<Setter TargetName="path" Property="Stroke" Value="Blue" />
										</Trigger>
									</ControlTemplate.Triggers>
								</ControlTemplate>
							</Setter.Value>
						</Setter>
					</Style>
				</Grid.Resources>
				<TextBlock x:Name="searchTextWatermark" Text="Search" VerticalAlignment="Center"
						HorizontalAlignment="Left" Margin="5,0,0,0" Foreground="#FFA9A9A9" />
				<TextBox x:Name="searchText" Background="Transparent" VerticalContentAlignment="Center" Padding="2"
						TextChanged="searchText_TextChanged" />
				<Button x:Name="cancelSearchButton" Style="{StaticResource CancelButton}"
						Content="M 0.5 0.5 7.5 7.5 M 0.5 7.5 7.5 0.5" HorizontalAlignment="Right"
						VerticalAlignment="Center" Visibility="Hidden" Click="cancelSearchButton_Click" />
			</Grid>
			<Button Content="_Close" IsCancel="True" Grid.Column="1" Margin="10,20,20,20" VerticalAlignment="Center"
					Command="ext:SystemCommands.CloseWindowCommand" />
		</Grid>
	</Grid>
</office:OfficeWindow >
